package com.kqmanage.action;

import java.util.Map;
import com.kqmanage.entity.Admin;
import com.kqmanage.service.AdminService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class AdminAction extends ActionSupport {
	private Admin admin;
	private AdminService service;

	public String Login() {
		Admin currentUser = service.login(admin.getAname(),
				admin.getApassword());
		// 判断用户名密码是否匹配
		if (currentUser != null) {
			ActionContext context = ActionContext.getContext();
			Map<String, Object> session = context.getSession();
			session.put("currentUser", currentUser);
			return SUCCESS;
		} else {
			addActionError("用户名或密码错误!");
			return INPUT;
		}
	}
}
